package cn.wolfcode.service;

import cn.wolfcode.domain.OperateIntegralVo;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

@LocalTCC   // seata-TCC模式注解
public interface IUsableIntegralService {

    /**
     * 减少积分逻辑
     * @param operateIntegralVo
     */
    void decrIntegral(OperateIntegralVo operateIntegralVo);

    /**
     * 增加积分逻辑
     * @param operateIntegralVo
     */
    void incrIntegral(OperateIntegralVo operateIntegralVo);


    /**
     * 增加积分
     */
    @TwoPhaseBusinessAction(
            name = "incrIntegralTry",
            commitMethod = "incrIntegralCommit",
            rollbackMethod = "incrIntegralRollback")
    void incrIntegralTry(@BusinessActionContextParameter(paramName = "operateIntegralVo") OperateIntegralVo operateIntegralVo, BusinessActionContext context);
    void incrIntegralCommit(BusinessActionContext context);
    void incrIntegralRollback(BusinessActionContext context);

    /**
     * 减少积分
     */
    @TwoPhaseBusinessAction(
            name = "decrIntegralTry",
            commitMethod = "decrIntegralCommit",
            rollbackMethod = "decrIntegralRollback")
    void decrIntegralTry(@BusinessActionContextParameter(paramName = "operateIntegralVo") OperateIntegralVo operateIntegralVo, BusinessActionContext context);
    void decrIntegralCommit(BusinessActionContext context);
    void decrIntegralRollback(BusinessActionContext context);

}
